home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: undoInsertLargeData.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:04 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "pool.h"
- #include "log.h"
- #include "volume.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "logaction.h"
- #include "openlog.h"
- #include "undo.h"
- #include "undo_extfuncs.h"
- #include "bf_extfuncs.h"
- #include "log_extfuncs.h"
- #include "log_intfuncs.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "trans_globals.h"
- #include "sm_macro.h"
- #ifdef INIT_LRC_IS_LSN
- # include "log_globals.h"
- #endif
-
- void
- undoInsertLargeData (
-
- LOGRECORDHDR *recordHeader
- )
- {
-
- GROUPLINK *groupLink;
- LGDATAPAGE *lgDataPage;
- char *oldData;
- int oldDataSize;
- PID *pid;
- LGWRITEINFO *lgWriteInfo;
- LGWRITEINFO newLgWriteInfo;
- LOGRECORDINFO recordInfo;
- #ifdef INIT_LRC_IS_LSN
- LRC tempLRC;
- LRC *lrc = &tempLRC;
- #else
- LRC *lrc;
- #endif /* INIT_LRC_IS_LSN; */
- LSN lsn;
- FORCEMARK forceMark;
- BOOL actionDone; /* Indicates whether the action
- was ever performed on the page */
- int i;
- INIT_MISSING_UPDATE_INFO( Active->transRec );
-
- TRPRINT(TR_IO, TR_LEVEL_1, ("lsn:%d", recordHeader->recordLSN));
-
- /* get a pointer to the page for the record */
- pid = &(recordHeader->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- /* get pointer to oid, header info */
- lgWriteInfo = (LGWRITEINFO*) GET_LOG_IMAGE(recordHeader, 0);
-
- if (recordHeader->action == LOG_ACTION_INSERT_LARGE_DATA) {
- /* get a pointer to the old data and its size in the record */
- oldData = GET_LOG_IMAGE(recordHeader, 1);
- oldDataSize = GET_LOG_IMAGE_SIZE(recordHeader, 1);
- SM_ASSERT(LEVEL_3, oldDataSize == lgWriteInfo->size);
- } else {
- SM_ASSERT(LEVEL_3, recordHeader->action == LOG_ACTION_INSERT_LARGE_DATA_ND);
- }
-
- /*
- * read in the page
- */
- if ((groupLink = bf_ReadPage(UserBufGroup, pid, LGDATA_PAGE2SIZE, BF_SEM)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /* get a pointer to the large data page */
- lgDataPage = (LGDATAPAGE *) groupLink->bufFrame;
- CHECK_LGDATAHDR_MAGIC(lgDataPage);
-
- /* See if the action was actually done */
- actionDone = compareLRC(&(recordHeader->actionLRC), &(lgDataPage->header.lrc) ) <= 0;
-
- /*
- * it is possible that the action
- * never made it to the page on the server, so missing update
- * information may need to be recorded
- *
- * Process any missing updates, and return a pointer to
- * the lrc to increment. This will either be the lrc on the
- * slotted page, or the lrc in the missingUpdatePageTable
- */
- RECORD_MISSING_UPDATE( actionDone, &lrc, missingUpdateInfo, pid,
- &(lgDataPage->header.lrc),
- groupLink->pageHash, recordHeader, PAGE_LARGEDATA);
-
- /* increment the lrc on the page */
- GENERATE_LRC(lrc);
-
- newLgWriteInfo = *lgWriteInfo;
- newLgWriteInfo.prevSize = lgWriteInfo->prevSize + lgWriteInfo->size;
-
- /*
- * Log the undo write
- */
- recordInfo.action = LOG_ACTION_DELETE_LARGE_DATA;
- recordInfo.type = LOG_REC_TYPE_COMPENSATION;
- recordInfo.imageCount = 1;
- recordInfo.actionPid = pid;
- recordInfo.actionLRC = lrc;
- recordInfo.imageSize[0] = sizeof(LGWRITEINFO);
- recordInfo.imageData[0] = (VOID *) &newLgWriteInfo;
- recordInfo.nextUndoLSN = recordHeader->previousLSN;
- recordInfo.flags = NOFLAGS;
-
- /* write the record to the log */
- if ((forceMark = writeLogRecord((TRANSREC *) Active->transRec, &recordInfo,
- &lsn, NOFLAGS)) < 0) {
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /* mark the page dependency */
- #ifndef INIT_LRC_IS_LSN
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
- #endif
-
- /* perform the undo, if the action was performed */
- if (actionDone) {
-
- #ifdef INIT_LRC_IS_LSN
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
- #endif
-
- /* Delete the inserted data */
- for (i = lgWriteInfo->start+oldDataSize; i < lgWriteInfo->prevSize+oldDataSize; i++) {
- lgDataPage->data[i-oldDataSize] = lgDataPage->data[i];
- }
- CHECK_LGDATAHDR_MAGIC(lgDataPage);
- }
-
- /*
- * release the semaphore and unfix the page, dirty the page if
- * the action was done
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
- bf_UnfixPage(groupLink, BF_DEFAULT, actionDone);
-
- return;
- }
-